<?php

if(isset($_GET['idArt']))
{
	//Pagination comments
	// $limit = $limit = ' LIMIT 0, '.NB_COMMENTS_PER_PAGE;
	// $nbComments = count(Comment::listing("WHERE COM_IdArticle = ".$_GET['idArt']));
	// $nbPages=ceil($nbComments/NB_COMMENTS_PER_PAGE);
	
	// if(isset($_GET['numPageComs']))
	// {
		// $from= (NB_COMMENTS_PER_PAGE*($_GET['numPageComs']-1))+1;
		// $to=NB_COMMENTS_PER_PAGE;
		// $limit = ' LIMIT '.$from.', '.$to;
	// }
	
	// Record a comment
	if(isset($_POST['comment']))
	{
		$comment = new Comment($_POST['comment'],$_SESSION['idUser'], $_GET['idArt']);
		$comment->save();
	}
	
	// Deleting a comment by changing the content
	if(isset($_GET['supprCom']))
	{
		$com = Comment::read($_GET['supprCom']);
		$com->setContentCom("<em>Supprim&eacute;</em>");
		$com->save();
		echo $com->toString();
	}
		
	$article =  Article::read($_GET['idArt']);
	$listComs = Comment::listing("WHERE COM_IdArticle = ".$_GET['idArt']);
	//count(Comment::listing("WHERE COM_IdArticle =".$article->getIdArt()));
	// 
	include_once("partials/article.php");
}
else
	echo "Oups ! Il semblerait que l'article demand&eacute; n'existe pas.";

	
			


?>